<template>
  <!-- 明细页面弹出框-->
  <el-dialog
    title="数字证书绑定管理审核明细"
    center
    :visible.sync="open"
    width="1024px"
    :close-on-click-modal="true"
    @close="closeFn"
  >
    <el-form ref="detailsForm" :model="formData" label-width="170px">
      <el-row type="flex">
        <el-col :span="24">
          <el-form-item label="交易流水号：" prop="id">
            <el-input v-model="formData.id" placeholder="" disabled />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex">
        <el-col :span="24">
          <el-form-item label="直接参与机构号：" prop="directOrg">
            <el-input v-model="formData.directOrg" placeholder="" disabled />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex">
        <el-col :span="24">
          <el-form-item label="直接参与机构名称：" prop="directOrgName">
            <el-input v-model="formData.directOrgName" placeholder="" disabled />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="变更类型：" prop="chgType">
            <el-select v-model="formData.chgType" placeholder="" style="width: 100%" disabled>
              <el-option
                v-for="dict in dictMap.CHANGECODE"
                :key="dict.value"
                :label="`${dict.value}-${dict.text}`"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex">
        <el-col :span="24">
          <el-form-item label="证书DN：" prop="certDnTemp">
            <el-input v-model="formData.certDnTemp" placeholder="" disabled />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex">
        <el-col :span="24">
          <el-form-item label="备注：" prop="remark">
            <el-input type="textarea" v-model="formData.remark" disabled />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="录入操作员：" prop="mdTlrno">
            <el-input v-model="formData.mdTlrno" placeholder="" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="录入时间：" prop="mdTime">
            <el-date-picker
              v-model="formData.mdTime"
              type="datetime"
              value-format="yyyyMMddHHmmss"
              placeholder=""
              disabled
              style="width: 100%"
            ></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex">
        <el-col :span="24">
          <el-form-item label="审核附言：" prop="audRemarks">
            <el-input type="textarea" v-model="formData.audRemarks" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="approveFn" :loading="isLoading">审核</el-button>
      <el-button type="warning" @click="rejectFn" :loading="isLoading">拒绝</el-button>
    </div>
  </el-dialog>
</template>
<script>
import { approve, reject } from "@/api/cnaps/ccms/903/digital_certificate_approve.js";
export default {
  name: "DigitalCertificateApproveDetails",
  components: {},
  props: {
    dictMap: {
      type: Object,
      default: () => {
        return {};
      },
    },
    formData: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      // 是否显示弹出层
      open: false,
      isLoading: false,
    };
  },
  mounted() {},
  methods: {
    // 审核方法
    approveFn() {
      this.isLoading = true;
      approve(this.formData)
        .then((res) => {
          this.isLoading = false;
          this.$emit("editComplete", true);
          this.msgSuccess("已审批!");
          this.closeFn();
        })
        .catch((err) => {
          this.isLoading = false;
          this.$alert(`${res.result}`, "系统提示", {
            confirmButtonText: "确认",
            type: "error",
            callback: (action) => {},
          });
        });
    },
    // 拒绝方法
    rejectFn() {
      this.isLoading = true;
      reject(this.formData)
        .then((res) => {
          this.isLoading = false;
          this.$emit("editComplete", true);
          this.msgSuccess("已拒绝!");
          this.closeFn();
        })
        .catch((err) => {
          this.isLoading = false;
          this.$alert(`${res.result}`, "系统提示", {
            confirmButtonText: "确认",
            type: "error",
            callback: (action) => {},
          });
        });
    },
    // 表单重置
    reset() {
      this.resetForm("detailsForm");
    },
    closeFn() {
      this.open = false;
      this.reset();
    },
    show() {
      this.open = true;
    },
  },
};
</script>
